<?php
/**
 * RoomBooking View for RoomBooking Component
 * 
 * @version 1.0
 * @package    Joomla
 * @subpackage RoomBooking
 * @copyright (C) 2011 Giovanni Marzulli
 * @license		GNU/GPL
*/
 
// no direct access
 
defined( '_JEXEC' ) or die( 'Restricted access' );
 
jimport( 'joomla.application.component.view');

class RoomBookingViewRoomBooking extends JView
{
	/**
     * RoomBooking view display method
     * @return void
     **/
    function display($tpl = null)
    {
    	$id_room=JRequest::getVar('id_room');
		$layout =$this->getLayout();
		$organizationid=JRequest::getVar('organizationid');
		$buildingid=JRequest::getVar('buildingid');
		if(!isset($organizationid) && !isset($buildingid) && $this->getLayout()=='dyn_select')  
				$this->setLayout('default');
	
		$modelOrganizations =& $this->getModel('organizations');
		$organizations = $modelOrganizations->getOrganizations();
		$this->assignRef( 'organizations', $organizations );
		
      	  parent::display($tpl);
    }
    
    /**
     * Gets buildings of an organization
     * @return array
     **/
    function getBuildings($id) {
		$modelBuildings =& $this->getModel('buildings');
        $buildings = $modelBuildings->getBuildings($id);
		return $buildings;
	}
	
	/**
     * Gets rooms of a building
     * @return array
     **/
   function getRooms($id) {
		$modelRooms =& $this->getModel('rooms');
                $rooms = $modelRooms->getRoomsOfBuilding($id);
		return $rooms;
	}
	
}
